YouTip LogoYouTip

File Writelines

# Open the file fo = open("test.txt", "w") print("File name: "), fo.name seq = [" 1n", " 2"] fo.writelines( seq ) # Close the file fo.close()

The output of the above example is:

File name:  test.txt

View the file content:

$ cat test.txt
 1
 2

Python File Methods Python File Methods

Python File I/O

Python Exceptions

ByteArk Coding Plan supports mainstream large models such as Doubao, GLM, DeepSeek, Kimi, MiniMax, officially supplied, stable and reliable.

Xunfei Star Coding Plan includes free model call quotas, DeepSeek, GLM, Kimi, MiniMax, a one-stop experience and deployment platform. Configuration Guide Β₯3.9/month Subscribe Now

Click to Share Notes

Cancel

Write notes...

Image URL

Image description

Image size Γ—

Share notes

  • Nickname Nickname (Required)
  • Email Email (Required)
  • Reference URL Reference URL

Category Navigation

← File WritelinesFile Seek β†’