File creation with Python
How to use A.I service Allen post 'GPT-4 is free? (Feat. AI Service Alan)' Remember that? We introduced this Alan(Alan) to automate the task of creating arbitrary files, renaming them, and extracting their filenames. In this post, we'll keep things short and simple by first creating a txt file.
* If you want to see the pictures in the text in a little more detail, click on them to enlarge them.
Coding with AI overview
In fact, there are some repetitive tasks in the office, such as working in Excel or creating files. If you let Python take care of these tasks and focus on more productive things, you'll get a lot done. But how can you do that if you don't even know how to code?
You only need to do three things. First, connect to an AI service like Alan and tell it what you want. Request coding. Second, copy the source code that Alan created and add it to an integrated development environment (IDE) program such as VS Code using the Paste and run. Third, if you don't get the results you want, you can work with Alan to create a Complementing source code modifications .
Alan is not perfect with 100%, and if I don't ask good detailed questions, it doesn't give me good results. If I have a problem with the generated source code, VS Code will usually give me an error message, which I can use to ask Alan.
Requesting Python source code written for you
Create 10 txt files in a specific folder, but python code them to have 240310 at the end of the filename.
First, we'll perform the task of gaslighting Alan. "You're a Python expert now, okay?into the command window and hit enter, and it responds by saying something. Then I give it the command below, and it responds as shown. It says what I asked it one more time, telling me what I need to consider further. True to its word, it creates the folder for me and puts the path to it in the source code.
It generates the source code, as shown above, with a rough description of what Alan is asking for. What do we do now? We copy the source code and paste it into VS Code. Of course, we can't guarantee that it will give us the same answer if we ask it the same question.
import os
# Change to your desired folder path.
directory = 'your_directory'
# Generate 10 txt files.
for i in range(1, 11):
filename = os.path.join(directory, f'file{i}_240310.txt')
with open(filename, 'w') as f:
passPaste and run the source code
Paste (copy and paste) the source code as shown in the following figure, (1) specify the folder to create the txt file, and (2) click the Run Source Code button (▷). In my case, I created a folder named source_code on my C drive ( C:\source_code ).
When we run the source code, we can see that the Python command is automatically entered and executed in the terminal window and 10 TXT files are created in the folder we specified, as shown in the following image. Wow, isn't that amazing?
Organize
In this post, I generated the code source using the AI service and executed it in VS Code to check the result. How about it? It's not that hard, right? Of course, it can be a little annoying if you have a problem with the source code, feedback to Alan, and do it two or three times, but this time it was simple and Hankyu solved it.
Python! I can do that black stuff! I'm sure your confidence is +1. Help me make a life bouquet, Terry on secondlife.lolwas.
All content on 'secondlife.lol' is protected by copyright law. Unauthorized reprinting, copying, distribution, etc. is prohibited.








