How to create files with specific extensions?

QuestionsQuestions8 SkillsProPermissions of FilesOct, 21 2025
0117

To create files with specific extensions, you can use a text editor or command line tools. Here are a few examples:

Using Command Line

  1. Create a Python file:

    touch my_script.py
  2. Create a text file:

    touch my_file.txt
  3. Create a JavaScript file:

    touch my_script.js

Using a Text Editor

  1. Open your preferred text editor (e.g., VSCode, Sublime Text, or Notepad).
  2. Create a new file.
  3. Save the file with the desired extension (e.g., my_file.py, my_file.txt, my_file.js).

Example in Python

If you want to create a file programmatically in Python:

with open('my_file.txt', 'w') as file:
    file.write('Hello, World!')

This will create a text file named my_file.txt with the content "Hello, World!". Adjust the file name and extension as needed.

0 Comments

no data
Be the first to share your comment!