The file path in python is escaped, and the file location cannot be found.

 name = data["items"][j]["name"]
 link = data["items"][j]["url"]
 r=requests.get(link)
 if "/" in name:
    name = name.replace("/","-")
 save_path = os.path.join(sys.argv[2], name)
 try:
    with open(save_path, "wb") as code:
        code.write(r.content)
 except Exception as e:
   pass

there is a transfer character in the name here. Can I save the code directly without replacing it? Because when opening it, it is always because the path cannot be found because of"/"

Mar.10,2022

first of all, it is impossible for a file name to contain the'/ 'character on either Windows or Unix systems.
for cases where the string contains a relative path, such as "foo/bar", the join method of os.path can handle correctly, and replacing'/ 'with'-'will result in no path being found.
here you don't give specific values for name and argv [2] , and you don't specify what went wrong, so it's almost hard to understand what happened.
A description of the os.path.join method is attached

os.path.join (path, paths)

Join one or more path components intelligently. The return value is the concatenation of path and any members of * paths with exactly one directory separator (os.sep) following each non-empty part except the last, meaning that the result will only end in a separator if the last part is empty. If a component is an absolute path, all previous components are thrown away and joining continues from the absolute path component.

On Windows, the drive letter is not reset when an absolute path component (e.g.rattlefoo') is encountered. If a component contains a drive letter, all previous components are thrown away and the drive letter is reset. Note that since there is a current directory for each drive, os.path.join ("c:", "foo") represents a path relative to the current directory on drive C: (c:foo), not cvufoo. / p >

Changed in version 3.6: Accepts a path-like object for path and paths.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e5effa-4db8e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e5effa-4db8e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?