Автор: ddantgwyn
Дата: 02-04-25 22:11
Vinsent написа:
> Проблемът, с който се сблъсках, е при работа с файлове. Например, при командата open не си намира
> файла. Нещо бъркам в синтаксиса или съм направил грешна инсталация? Ако можеш да ми помогнеш, ще ти бъда много благодарен!
командата
$ open filename
търси файла в директорията, в която се намираш. Ако го няма, няма как да го отвори. Тогава трябва да укажеш пътя до него и командата добива следния вид
$ open /path/to/the/file/filename.
А ако искаш повече помощ, бъди по-конкретен с примерите, pls. Например как точно се опитваш да отвориш файла - в терминал или вътре в самия python.
Ето например какво ще ти покаже самия python за оператора open в него:
open(
file,
mode='r',
buffering=-1,
encoding=None,
errors=None,
newline=None,
closefd=True,
opener=None
)
Open file and return a stream. Raise OSError upon failure.
file is either a text or byte string giving the name (and the path if the file isn't in the current working directory) of the file to be opened or an integer file descriptor of the file to be wrapped. (If a file descriptor is given, it is closed when the returned I/O object is closed, unless closefd is set to False.)
mode is an optional string that specifies the mode in which the file is opened. It defaults to 'r' which means open for reading in text mode. Other common values are 'w' for writing (truncating the file if it already exists), 'x' for creating and writing to a new file, and 'a' for appending (which on some Unix systems, means that all writes
Вярно, че не пиша от Macbook, но знаейки какво има под графичния интерфейс на Apple, мога да твърдя, че и при теб ще е подобен резултата.
|
|