i = "123"
with open("data.txt", 'w') as f:
out_file.write(str(i))
####
with open("data.txt") as f:
i = f.readlines()[0]
data = {
"name" : "RimMirK",
"id" : 148734,
"interval" : 3.5,
"is_answer" : True,
"message" : {
"lines" : [
"hello!",
"I'm RimMirK"
],
"id" : 136,
}
}
C:\Users\User>py
Python 3.10.8 (tags/v3.10.8:aaaf517, Oct 11 2022, 16:50:30) [MSC v.1933 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> text = '123'
>>> print('hello') if command in text for command in ["привет", "хай"]
File "<stdin>", line 1
print('hello') if command in text for command in ["привет", "хай"]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: expected 'else' after 'if' expression
>>> print('hello') if command in text else pass for command in ["привет", "хай"]
File "<stdin>", line 1
print('hello') if command in text else pass for command in ["привет", "хай"]
^^^^
SyntaxError: invalid syntax
>>> print('hello') if command in text else ... for command in ["привет", "хай"]
File "<stdin>", line 1
print('hello') if command in text else ... for command in ["привет", "хай"]
^^^
SyntaxError: invalid syntax
>>> print('hello') if command in text else print('',end='') for command in ["привет", "хай"]
File "<stdin>", line 1
print('hello') if command in text else print('',end='') for command in ["привет", "хай"]
^^^
SyntaxError: invalid syntax
>>> command print('hello') if command in text else print('',end='') for command in ["привет", "хай"]
File "<stdin>", line 1
command print('hello') if command in text else print('',end='') for command in ["привет", "хай"]
^^^^^
SyntaxError: invalid syntax
>>> print('hello') if command in text else print('',end='') command for command in ["привет", "хай"]
File "<stdin>", line 1
print('hello') if command in text else print('',end='') command for command in ["привет", "хай"]
^^^^^^^
SyntaxError: invalid syntax
>>> print('hello') if command in text else print('',end='') for command in ["привет", "хай"]
File "<stdin>", line 1
print('hello') if command in text else print('',end='') for command in ["привет", "хай"]
^^^
SyntaxError: invalid syntax
import os
import sys
# Returns the directory the current script (or interpreter) is running in
def get_script_directory():
path = os.path.realpath(sys.argv[0])
if os.path.isdir(path):
return path
else:
return os.path.dirname(path)
btn = f"{get_script_directory()}\\ASD.png"
with open('data/accounts.txt', 'r') as file:
- lines = file.readlines()
+ line = file.readlines()[1]
- for x in lines:
- login, password = x.split(':')[0], x.split(':')[1]
+ login, password = x.split(':')
bot.send_message(message.chat.id, login + password)
with open('data/accounts.txt', 'r') as file:
line = file.readlines()[1]
login, password = x.split(':')
bot.send_message(message.chat.id, login + password)
def game(num, attempts_count):
# code
if int(direction) == 2:
new_num = random.randint(0, 10)
game(new_num, attempts_count)
import sys
print(sys.argv[1]) # Тут будет полный путь к файлу с которым вы сделали "Открыть с помощью"
# sys.argv[2] sys.argv[3] и тд если вы перетащите несколько файлов
while True:
one = float( input ("Введите первое число: "))
two = float( input ("Введите второе число: "))
print ("Вы можете выбрать несколько действий: + - * /")
day = input ("Введите ваше действие: ")
if day == "*":
down = one * two
print ( down )
if day == "/":
down = one / two
print ( down )
if day == "-":
down = one - two
print ( down )
if day == "+":
down = one + two
print ( down )
else:
print ("Или вы пишите что-то непонятное или мой калькулятор так не умеет :(")