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, 2020 in Python by akhtar
• 38,180 points
191 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, 2020 by MD
• 95,140 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
137 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
• 930 points
543 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 May 27, 2020 in Python by Niroj
• 82,680 points
5,580 views
0 votes
2 answers
+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 1,994 views
0 votes
0 answers
+4 votes
6 answers

Lowercase in Python

You can simply the built-in function in ...READ MORE

answered Apr 11, 2018 in Python by hemant
• 5,810 points
1,532 views
0 votes
1 answer

How to remove a file using the OS module in Python?

Hi@akhtar, In Python, you can use the os. remove() method to remove ...READ MORE

answered Oct 17, 2020 in Python by MD
• 95,140 points
140 views
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, 2020 in Python by MD
• 95,140 points
163 views