How to write right to left in text file with python?

Viewed 49

I'm struggling to write with PYTHON 3 in text file a string which contains Hebrew which is a language who is wrote from right to left.

my issue is that i have one variable who contains Hebrew and I need to concatenate it to a bigger string , is name is record.

I wrote also an ljust() method which is just left align the string

Order_interface_2 = '$Order_interface_2$'.ljust(1)
Contract_num= '$Contract_num$'.ljust(12)
Item_num = '$Item_num$'.rjust(5)
Material_code = '$Material_code$'.ljust(18)
Item_cat = '$Item_cat$'.ljust(1)
Account_Category= '$Account_Category$'.ljust(1)
Material_group= '$Material_group$'.ljust(9)

Short_Text= '$Short_Text$'.ljust(40)


Indicator= '$Indicator$'.ljust(1)
Plant = '$Plant$'.ljust(4)
Order_unit = '$Order_unit$'.ljust(3)
Net_price = '$Net_price$'.rjust(25)
Tax_code = '$Tax_code$'.ljust(2)
PO_quantity= '$PO_quantity$'.rjust(15)
Update_info= '$Update_info$'.ljust(1)
Overdelivery= '$Overdelivery$'.ljust(1)
Underdelivery= '$Underdelivery$'.rjust(5)
Indicator_Goods= '$Indicator_Goods$'.ljust(1)
Non_Valuated_Goods= '$Non_Valuated_Goods$'.ljust(1)
Delivery_Comp= '$Delivery_Comp$'.ljust(1)
Final_invoice= '$Final_invoice$'.ljust(1)



record = Order_interface_2 + Contract_num + Item_num + Material_code + Item_cat + Account_Category + Material_group  + Short_Text + Indicator + Plant + Order_unit + Net_price + Tax_code + PO_quantity + Update_info + Overdelivery +Underdelivery+ Indicator_Goods + Non_Valuated_Goods + Delivery_Comp + Final_invoice

print(record)

I concatenated all the variables together to get one big string => record

the Variable Short_Text contains the Hebrew string.

Now for the example I tried to wrote in English in my first try. So the Short_text was in English at this moment and it was like this, I highlighted the string in the row it wrote it like this :

first try in English

but when I changed to Hebrew , all the variables who come after that changed their positions

second try in hebrew

How can I do to get the same positions for those variables who come after Hebrew ??? as it was in English ??

0 Answers
Related