How to transfer multiple lines in a file using python?

0 votes

I have a scenario where I have to transfer multiple lines in a file for my TUI project. How to do this task?

Mar 31 in Python by akhtar
• 10,580 points
68 views

1 answer to this question.

0 votes

Hi@akhtar,

I don't know it will help you or not. But you can use the bellow given code.

line1="First line"
line2="Second line"
line3="Third line"
with open('/root/abc.txt','w') as out:
    out.writelines([line1,line2,line3])

Thank You

answered Mar 31 by MD
• 22,970 points

Related Questions In Python

0 votes
0 answers

How to implement multiple try codes in a single block using Python?

Hi all, As per the title, I am ...READ MORE

Jan 14, 2019 in Python by Anirudh
• 2,080 points
75 views
+1 vote
1 answer

How to check if a string is in a file, using python?

Hi, Try the below given code: with open('myfile.txt') as ...READ MORE

answered Jul 4, 2019 in Python by Shabnam
• 920 points
157 views
0 votes
1 answer

How to get the latest file in a folder using python?

Hello @kartik,  would suggest using glob.iglob() instead of the glob.glob(), as ...READ MORE

answered 6 days ago in Python by Niroj
• 22,790 points
22 views
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 947 views
0 votes
0 answers
+4 votes
6 answers
0 votes
1 answer

How to crop face from a photo using cv2 in python?

Hi@akhtar, You can do this task using cv2 ...READ MORE

answered Apr 9 in Python by MD
• 22,970 points
42 views
0 votes
1 answer

How to read photo using cv2 module in python?

Hi@akhtar, Yes, you can read your image in ...READ MORE

answered Apr 9 in Python by MD
• 22,970 points
29 views