Как мне импортировать json файл из Python в cmd batch?
Как мне сделать импортирование из json файла в python, а затем в cmd batch file?
json file:
{
"username": "НИК"
}
Batch file:
start game username "НИК" nogui stop sound
Исходники:
Batch file
echo off
cls
title МОЖЕТЕ ЗАКРЫТЬ ДАННОЕ ОКНО ЕСЛИ ОНО ВАМ МЕШАЕТ! РАЗРАБОТЧИК КРИВОРУКИЙ НЕ УМЕЕТ ДЕЛАТЬ ЛАУНЧЕРА ДЛЯ MINECRAFT 1.18.2!
echo МОЖЕТЕ ЗАКРЫТЬ ДАННОЕ ОКНО!!!
echo ░██████╗████████╗░█████╗░██████╗░████████╗ ███╗░░░███╗██╗███╗░░██╗███████╗░█████╗░██████╗░░█████╗░███████╗████████╗
echo ██╔════╝╚══██╔══╝██╔══██╗██╔══██╗╚══██╔══╝ ████╗░████║██║████╗░██║██╔════╝██╔══██╗██╔══██╗██╔══██╗██╔════╝╚══██╔══╝
echo ╚█████╗░░░░██║░░░███████║██████╔╝░░░██║░░░ ██╔████╔██║██║██╔██╗██║█████╗░░██║░░╚═╝██████╔╝███████║█████╗░░░░░██║░░░
echo ░╚═══██╗░░░██║░░░██╔══██║██╔══██╗░░░██║░░░ ██║╚██╔╝██║██║██║╚████║██╔══╝░░██║░░██╗██╔══██╗██╔══██║██╔══╝░░░░░██║░░░
echo ██████╔╝░░░██║░░░██║░░██║██║░░██║░░░██║░░░ ██║░╚═╝░██║██║██║░╚███║███████╗╚█████╔╝██║░░██║██║░░██║██║░░░░░░░░██║░░░
echo ╚═════╝░░░░╚═╝░░░╚═╝░░╚═╝╚═╝░░╚═╝░░░╚═╝░░░ ╚═╝░░░░░╚═╝╚═╝╚═╝░░╚══╝╚══════╝░╚════╝░╚═╝░░╚═╝╚═╝░░╚═╝╚═╝░░░░░░░░╚═╝░░░
C:\Users\Fps_M\AppData\Roaming\.tlauncher\legacy\Minecraft\jre\java-runtime-beta\windows-x64\java-runtime-beta\bin\javaw.exe -XX:+UnlockExperimentalVMOptions -XX:+UseG1GC -XX:G1NewSizePercent=20 -XX:G1ReservePercent=20 -XX:MaxGCPauseMillis=50 -XX:G1HeapRegionSize=32M -XX:+DisableExplicitGC -XX:+AlwaysPreTouch -XX:+ParallelRefProcEnabled -Xms512M -Xmx2816M -Dfile.encoding=UTF-8 -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump "-Djava.library.path=C:\Users\Fps_M\AppData\Roaming\.tlauncher\legacy\Minecraft\game\versions\ForgeOptiFine 1.18.2\natives" -Dminecraft.launcher.brand=java-minecraft-launcher -Dminecraft.launcher.version=1.6.84-j -cp "C:\Users\Fps_M\AppData\Roaming\.tlauncher\legacy\Minecraft\game\libraries\pw\modder\transformerDiscoverer\2.2\transformerDiscoverer-2.2.jar;C:\Users\Fps_M\AppData\Roaming\.tlauncher\legacy\Minecraft\game\libraries\cpw\mods\securejarhandler\1.0.8\securejarhandler-1.0.8.jar;C:\Users\Fps_M\AppData\Roaming\.tlauncher\legacy\Minecraft\game\libraries\org\ow2\asm\asm\9.5\asm-9.5.jar;C:\Users\Fps_M\AppData\Roaming\.tlauncher\legacy\Minecraft\game\libraries\org\ow2\asm\asm-commons\9.5\asm-commons-9.5.jar;C:\Users\Fps_M\AppData\Roaming\.tlauncher\legacy\Minecraft\game\libraries\org\ow2\asm\asm-tree\9.5\asm-tree-9.5.jar;C:\Users\Fps_M\AppData\Roaming\.tlauncher\legacy\Minecraft\game\libraries\org\ow2\asm\asm-util\9.5\asm-util-9.5.jar;C:\Users\Fps_M\AppData\Roaming\.tlauncher\legacy\Minecraft\game\libraries\org\ow2\asm\asm-analysis\9.5\asm-analysis-9.5.jar;C:\Users\Fps_M\AppData\Roaming\.tlauncher\legacy\Minecraft\game\libraries\net\minecraftforge\accesstransformers\8.0.4\accesstransformers-8.0.4.jar;C:\Users\Fps_M\AppData\Roaming\.tlauncher\legacy\Minecraft\game\libraries\org\antlr\antlr4-runtime\4.9.1\antlr4-runtime-4.9.1.jar;C:\Users\Fps_M\AppData\Roaming\.tlauncher\legacy\Minecraft\game\libraries\net\minecraftforge\eventbus\5.0.3\eventbus-5.0.3.jar;C:\Users\Fps_M\AppData\Roaming\.tlauncher\legacy\Minecraft\game\libraries\net\minecraftforge\forgespi\4.0.15-4.x\forgespi-4.0.15-4.x.jar;C:\Users\Fps_M\AppData\Roaming\.tlauncher\legacy\Minecraft\game\libraries\net\minecraftforge\coremods\5.0.1\coremods-5.0.1.jar;C:\Users\Fps_M\AppData\Roaming\.tlauncher\legacy\Minecraft\game\libraries\cpw\mods\modlauncher\9.1.3\modlauncher-9.1.3.jar;C:\Users\Fps_M\AppData\Roaming\.tlauncher\legacy\Minecraft\game\libraries\net\minecraftforge\unsafe\0.2.0\unsafe-0.2.0.jar;C:\Users\Fps_M\AppData\Roaming\.tlauncher\legacy\Minecraft\game\libraries\com\electronwill\night-config\core\3.6.4\core-3.6.4.jar;C:\Users\Fps_M\AppData\Roaming\.tlauncher\legacy\Minecraft\game\libraries\com\electronwill\night-config\toml\3.6.4\toml-3.6.4.jar;C:\Users\Fps_M\AppData\Roaming\.tlauncher\legacy\Minecraft\game\libraries\org\apache\maven\maven-artifact\3.6.3\maven-artifact-3.6.3.jar;C:\Users\Fps_M\AppData\Roaming\.tlauncher\legacy\Minecraft\game\libraries\net\jodah\typetools\0.8.3\typetools-0.8.3.jar;C:\Users\Fps_M\AppData\Roaming\.tlauncher\legacy\Minecraft\game\libraries\net\minecrell\terminalconsoleappender\1.2.0\terminalconsoleappender-1.2.0.jar;C:\Users\Fps_M\AppData\Roaming\.tlauncher\legacy\Minecraft\game\libraries\org\jline\jline-reader\3.12.1\jline-reader-3.12.1.jar;C:\Users\Fps_M\AppData\Roaming\.tlauncher\legacy\Minecraft\game\libraries\org\jline\jline-terminal\3.12.1\jline-terminal-3.12.1.jar;C:\Users\Fps_M\AppData\Roaming\.tlauncher\legacy\Minecraft\game\libraries\org\spongepowered\mixin\0.8.5\mixin-0.8.5.jar;C:\Users\Fps_M\AppData\Roaming\.tlauncher\legacy\Minecraft\game\libraries\org\openjdk\nashorn\nashorn-core\15.3\nashorn-core-15.3.jar;C:\Users\Fps_M\AppData\Roaming\.tlauncher\legacy\Minecraft\game\libraries\net\minecraftforge\JarJarSelector\0.3.19\JarJarSelector-0.3.19.jar;C:\Users\Fps_M\AppData\Roaming\.tlauncher\legacy\Minecraft\game\libraries\net\minecraftforge\JarJarMetadata\0.3.19\JarJarMetadata-0.3.19.jar;C:\Users\Fps_M\AppData\Roaming\.tlauncher\legacy\Minecraft\game\libraries\cpw\mods\bootstraplauncher\1.0.0\bootstraplauncher-1.0.0.jar;C:\Users\Fps_M\AppData\Roaming\.tlauncher\legacy\Minecraft\game\libraries\net\minecraftforge\JarJarFileSystems\0.3.19\JarJarFileSystems-0.3.19.jar;C:\Users\Fps_M\AppData\Roaming\.tlauncher\legacy\Minecraft\game\libraries\net\minecraftforge\fmlloader\1.18.2-40.2.17\fmlloader-1.18.2-40.2.17.jar;C:\Users\Fps_M\AppData\Roaming\.tlauncher\legacy\Minecraft\game\libraries\com\mojang\logging\1.0.0\logging-1.0.0.jar;C:\Users\Fps_M\AppData\Roaming\.tlauncher\legacy\Minecraft\game\libraries\com\mojang\blocklist\1.0.10\blocklist-1.0.10.jar;C:\Users\Fps_M\AppData\Roaming\.tlauncher\legacy\Minecraft\game\libraries\ru\tln4\empty\0.1\empty-0.1.jar;C:\Users\Fps_M\AppData\Roaming\.tlauncher\legacy\Minecraft\game\libraries\com\github\oshi\oshi-core\5.8.5\oshi-core-5.8.5.jar;C:\Users\Fps_M\AppData\Roaming\.tlauncher\legacy\Minecraft\game\libraries\net\java\dev\jna\jna\5.10.0\jna-5.10.0.jar;C:\Users\Fps_M\AppData\Roaming\.tlauncher\legacy\Minecraft\game\libraries\net\java\dev\jna\jna-platform\5.10.0\jna-platform-5.10.0.jar;C:\Users\Fps_M\AppData\Roaming\.tlauncher\legacy\Minecraft\game\libraries\org\slf4j\slf4j-api\1.8.0-beta4\slf4j-api-1.8.0-beta4.jar;C:\Users\Fps_M\AppData\Roaming\.tlauncher\legacy\Minecraft\game\libraries\org\apache\logging\log4j\log4j-slf4j18-impl\2.17.0\log4j-slf4j18-impl-2.17.0.jar;C:\Users\Fps_M\AppData\Roaming\.tlauncher\legacy\Minecraft\game\libraries\com\ibm\icu\icu4j\70.1\icu4j-70.1.jar;C:\Users\Fps_M\AppData\Roaming\.tlauncher\legacy\Minecraft\game\libraries\com\mojang\javabridge\1.2.24\javabridge-1.2.24.jar;C:\Users\Fps_M\AppData\Roaming\.tlauncher\legacy\Minecraft\game\libraries\net\sf\jopt-simple\jopt-simple\5.0.4\jopt-simple-5.0.4.jar;C:\Users\Fps_M\AppData\Roaming\.tlauncher\legacy\Minecraft\game\libraries\io\netty\netty-all\4.1.68.Final\netty-all-4.1.68.Final.jar;C:\Users\Fps_M\AppData\Roaming\.tlauncher\legacy\Minecraft\game\libraries\com\google\guava\failureaccess\1.0.1\failureaccess-1.0.1.jar;C:\Users\Fps_M\AppData\Roaming\.tlauncher\legacy\Minecraft\game\libraries\com\google\guava\guava\31.0.1-jre\guava-31.0.1-jre.jar;C:\Users\Fps_M\AppData\Roaming\.tlauncher\legacy\Minecraft\game\libraries\org\apache\commons\commons-lang3\3.12.0\commons-lang3-3.12.0.jar;C:\Users\Fps_M\AppData\Roaming\.tlauncher\legacy\Minecraft\game\libraries\commons-io\commons-io\2.11.0\commons-io-2.11.0.jar;C:\Users\Fps_M\AppData\Roaming\.tlauncher\legacy\Minecraft\game\libraries\commons-codec\commons-codec\1.15\commons-codec-1.15.jar;C:\Users\Fps_M\AppData\Roaming\.tlauncher\legacy\Minecraft\game\libraries\com\mojang\brigadier\1.0.18\brigadier-1.0.18.jar;C:\Users\Fps_M\AppData\Roaming\.tlauncher\legacy\Minecraft\game\libraries\com\mojang\datafixerupper\4.1.27\datafixerupper-4.1.27.jar;C:\Users\Fps_M\AppData\Roaming\.tlauncher\legacy\Minecraft\game\libraries\com\google\code\gson\gson\2.8.9\gson-2.8.9.jar;C:\Users\Fps_M\AppData\Roaming\.tlauncher\legacy\Minecraft\game\libraries\by\ely\authlib\3.11.49.2\authlib-3.11.49.2.jar;C:\Users\Fps_M\AppData\Roaming\.tlauncher\legacy\Minecraft\game\libraries\org\apache\commons\commons-compress\1.21\commons-compress-1.21.jar;C:\Users\Fps_M\AppData\Roaming\.tlauncher\legacy\Minecraft\game\libraries\org\apache\httpcomponents\httpclient\4.5.13\httpclient-4.5.13.jar;C:\Users\Fps_M\AppData\Roaming\.tlauncher\legacy\Minecraft\game\libraries\commons-logging\commons-logging\1.2\commons-logging-1.2.jar;C:\Users\Fps_M\AppData\Roaming\.tlauncher\legacy\Minecraft\game\libraries\org\apache\httpcomponents\httpcore\4.4.14\httpcore-4.4.14.jar;C:\Users\Fps_M\AppData\Roaming\.tlauncher\legacy\Minecraft\game\libraries\it\unimi\dsi\fastutil\8.5.6\fastutil-8.5.6.jar;C:\Users\Fps_M\AppData\Roaming\.tlauncher\legacy\Minecraft\game\libraries\org\apache\logging\log4j\log4j-api\2.17.0\log4j-api-2.17.0.jar;C:\Users\Fps_M\AppData\Roaming\.tlauncher\legacy\Minecraft\game\libraries\org\apache\logging\log4j\log4j-core\2.17.0\log4j-core-2.17.0.jar;C:\Users\Fps_M\AppData\Roaming\.tlauncher\legacy\Minecraft\game\libraries\org\lwjgl\lwjgl\3.2.2\lwjgl-3.2.2.jar;C:\Users\Fps_M\AppData\Roaming\.tlauncher\legacy\Minecraft\game\libraries\org\lwjgl\lwjgl-jemalloc\3.2.2\lwjgl-jemalloc-3.2.2.jar;C:\Users\Fps_M\AppData\Roaming\.tlauncher\legacy\Minecraft\game\libraries\org\lwjgl\lwjgl-openal\3.2.2\lwjgl-openal-3.2.2.jar;C:\Users\Fps_M\AppData\Roaming\.tlauncher\legacy\Minecraft\game\libraries\org\lwjgl\lwjgl-opengl\3.2.2\lwjgl-opengl-3.2.2.jar;C:\Users\Fps_M\AppData\Roaming\.tlauncher\legacy\Minecraft\game\libraries\org\lwjgl\lwjgl-glfw\3.2.2\lwjgl-glfw-3.2.2.jar;C:\Users\Fps_M\AppData\Roaming\.tlauncher\legacy\Minecraft\game\libraries\org\lwjgl\lwjgl-stb\3.2.2\lwjgl-stb-3.2.2.jar;C:\Users\Fps_M\AppData\Roaming\.tlauncher\legacy\Minecraft\game\libraries\org\lwjgl\lwjgl-tinyfd\3.2.2\lwjgl-tinyfd-3.2.2.jar;C:\Users\Fps_M\AppData\Roaming\.tlauncher\legacy\Minecraft\game\libraries\com\mojang\text2speech\1.12.4\text2speech-1.12.4.jar;C:\Users\Fps_M\AppData\Roaming\.tlauncher\legacy\Minecraft\game\versions\ForgeOptiFine 1.18.2\ForgeOptiFine 1.18.2.jar" -Djava.net.preferIPv6Addresses=system "-DignoreList=bootstraplauncher,securejarhandler,asm-commons,asm-util,asm-analysis,asm-tree,asm,JarJarFileSystems,client-extra,fmlcore,javafmllanguage,lowcodelanguage,mclanguage,forge-,ForgeOptiFine 1.18.2.jar" -DmergeModules=jna-5.10.0.jar,jna-platform-5.10.0.jar,java-objc-bridge-1.0.0.jar -DlibraryDirectory=C:\Users\Fps_M\AppData\Roaming\.tlauncher\legacy\Minecraft\game\libraries -p C:\Users\Fps_M\AppData\Roaming\.tlauncher\legacy\Minecraft\game\libraries/cpw/mods/bootstraplauncher/1.0.0/bootstraplauncher-1.0.0.jar;C:\Users\Fps_M\AppData\Roaming\.tlauncher\legacy\Minecraft\game\libraries/cpw/mods/securejarhandler/1.0.8/securejarhandler-1.0.8.jar;C:\Users\Fps_M\AppData\Roaming\.tlauncher\legacy\Minecraft\game\libraries/org/ow2/asm/asm-commons/9.5/asm-commons-9.5.jar;C:\Users\Fps_M\AppData\Roaming\.tlauncher\legacy\Minecraft\game\libraries/org/ow2/asm/asm-util/9.5/asm-util-9.5.jar;C:\Users\Fps_M\AppData\Roaming\.tlauncher\legacy\Minecraft\game\libraries/org/ow2/asm/asm-analysis/9.5/asm-analysis-9.5.jar;C:\Users\Fps_M\AppData\Roaming\.tlauncher\legacy\Minecraft\game\libraries/org/ow2/asm/asm-tree/9.5/asm-tree-9.5.jar;C:\Users\Fps_M\AppData\Roaming\.tlauncher\legacy\Minecraft\game\libraries/org/ow2/asm/asm/9.5/asm-9.5.jar;C:\Users\Fps_M\AppData\Roaming\.tlauncher\legacy\Minecraft\game\libraries/net/minecraftforge/JarJarFileSystems/0.3.19/JarJarFileSystems-0.3.19.jar --add-modules ALL-MODULE-PATH --add-opens java.base/java.util.jar=cpw.mods.securejarhandler --add-opens java.base/java.lang.invoke=cpw.mods.securejarhandler --add-exports java.base/sun.security.util=cpw.mods.securejarhandler --add-exports jdk.naming.dns/com.sun.jndi.dns=java.naming -Dtransformers.list=optifine:OptiFine:1.18.2_HD_U_H9 -Xss2M cpw.mods.bootstraplauncher.BootstrapLauncher --username %1% --version "ForgeOptiFine 1.18.2" --gameDir C:\Users\Fps_M\AppData\Roaming\.tlauncher\legacy\Minecraft\game --assetsDir C:\Users\Fps_M\AppData\Roaming\.tlauncher\legacy\Minecraft\game\assets --assetIndex 1.18 --uuid e8717b21d14941f4b2ce6455e5a14a5b --accessToken eyJ0eXAiOiJKV1QiLCJhbGciOiJFUzI1NiJ9.eyJpYXQiOjE3MDc0ODUzOTksImNsaWVudF9pZCI6InRsYXVuY2hlciIsInNjb3BlIjoib2J0YWluX293bl9hY2NvdW50X2luZm8gbWluZWNyYWZ0X3NlcnZlcl9zZXNzaW9uIiwic3ViIjoiZWx5fDQ5NDU3OTcifQ.SybKJkqa7Bv2VV9Wv7tUdeJgGE3GTcBD1tle9wo766xxVzAUh7c9Cs2un6k7i1baGUXL1m1XAfgnmrZCkcPIsA --clientId "" --xuid "" --userType mojang --versionType modified --width 925 --height 530 --launchTarget forgeclient --fml.forgeVersion 40.2.17 --fml.mcVersion 1.18.2 --fml.forgeGroup net.minecraftforge --fml.mcpVersion 20220404.173914 --server 65.21.9.198 --port 25988
Python file:
from colorama import init, Fore #/
from colorama import Back #|
from colorama import Style #|
import msvcrt #|
import subprocess #|
import sys #|
import os #|
import time #|
import getpass #|
import json #|
#-----------Библы-----------------
os.system("title 〡ELauncher • Ядро: SCore")
# Открываем JSON
with open('C:/ELauncher/settings.json', 'r', encoding='utf-8') as file:
data = json.load(file)
# Забираем имя из словаря
username = data['username']
print("")
print(Fore.WHITE + " ███████╗██╗░░░░░░█████╗░██╗░░░██╗███╗░░██╗░█████╗░██╗░░██╗███████╗██████╗░")
print(Fore.WHITE + " ██╔════╝██║░░░░░██╔══██╗██║░░░██║████╗░██║██╔══██╗██║░░██║██╔════╝██╔══██╗")
print(Fore.BLUE + " █████╗░░██║░░░░░███████║██║░░░██║██╔██╗██║██║░░╚═╝███████║█████╗░░██████╔╝")
print(Fore.BLUE + " ██╔══╝░░██║░░░░░██╔══██║██║░░░██║██║╚████║██║░░██╗██╔══██║██╔══╝░░██╔══██╗")
print(Fore.RED + " ███████╗███████╗██║░░██║╚██████╔╝██║░╚███║╚█████╔╝██║░░██║███████╗██║░░██║")
print(Fore.RED + " ╚══════╝╚══════╝╚═╝░░╚═╝░╚═════╝░╚═╝░░╚══╝░╚════╝░╚═╝░░╚═╝╚══════╝╚═╝░░╚═╝")
print(Style.RESET_ALL)
print(" \033[41m От создателей EscapeWorld〡Выбран сервер: SCreate \033[0m")
print()
print(f"Ник:", username)
print("")
print("• Выберите пункт:")
print(" 1: Старт игры")
print(" 2: Выбор версии")
print(" 3: Настройка лаунчера")
def get_char():
return msvcrt.getch().decode('utf-8')
option = ""
current_directory = 'C:/ELauncher'
my_path = os.path.join(current_directory, 'start.bat')
while True:
key = get_char()
if key == "1":
os.system('cls' if os.name == 'nt' else 'clear')
print("")
print(Fore.WHITE + " ███████╗██╗░░░░░░█████╗░██╗░░░██╗███╗░░██╗░█████╗░██╗░░██╗███████╗██████╗░")
print(Fore.WHITE + " ██╔════╝██║░░░░░██╔══██╗██║░░░██║████╗░██║██╔══██╗██║░░██║██╔════╝██╔══██╗")
print(Fore.BLUE + " █████╗░░██║░░░░░███████║██║░░░██║██╔██╗██║██║░░╚═╝███████║█████╗░░██████╔╝")
print(Fore.BLUE + " ██╔══╝░░██║░░░░░██╔══██║██║░░░██║██║╚████║██║░░██╗██╔══██║██╔══╝░░██╔══██╗")
print(Fore.RED + " ███████╗███████╗██║░░██║╚██████╔╝██║░╚███║╚█████╔╝██║░░██║███████╗██║░░██║")
print(Fore.RED + " ╚══════╝╚══════╝╚═╝░░╚═╝░╚═════╝░╚═╝░░╚══╝░╚════╝░╚═╝░░╚═╝╚══════╝╚═╝░░╚═╝")
print(Style.RESET_ALL)
print(" \033[41m От создателей EscapeWorld〡Выбран сервер: SCreate \033[0m")
print("Введите ник:")
username = input("• ")
os.system('cls' if os.name == 'nt' else 'clear')
print("")
print(Fore.WHITE + " ███████╗██╗░░░░░░█████╗░██╗░░░██╗███╗░░██╗░█████╗░██╗░░██╗███████╗██████╗░")
print(Fore.WHITE + " ██╔════╝██║░░░░░██╔══██╗██║░░░██║████╗░██║██╔══██╗██║░░██║██╔════╝██╔══██╗")
print(Fore.BLUE + " █████╗░░██║░░░░░███████║██║░░░██║██╔██╗██║██║░░╚═╝███████║█████╗░░██████╔╝")
print(Fore.BLUE + " ██╔══╝░░██║░░░░░██╔══██║██║░░░██║██║╚████║██║░░██╗██╔══██║██╔══╝░░██╔══██╗")
print(Fore.RED + " ███████╗███████╗██║░░██║╚██████╔╝██║░╚███║╚█████╔╝██║░░██║███████╗██║░░██║")
print(Fore.RED + " ╚══════╝╚══════╝╚═╝░░╚═╝░╚═════╝░╚═╝░░╚══╝░╚════╝░╚═╝░░╚═╝╚══════╝╚═╝░░╚═╝")
print(Style.RESET_ALL)
print(" \033[41m От создателей EscapeWorld〡Выбран сервер: SCreate \033[0m")
print("Ник:", username, "выполняется вход...")
time.sleep(2.5)
#print(Fore.RED + " |-> Ошибка! Поставлен игровой-ник: MissingName")
time.sleep(4.5)
#print("Проверяю...") # - dev.click.openweb
os.system('cls' if os.name == 'nt' else 'clear')
print("")
print(Fore.WHITE + " ███████╗██╗░░░░░░█████╗░██╗░░░██╗███╗░░██╗░█████╗░██╗░░██╗███████╗██████╗░")
print(Fore.WHITE + " ██╔════╝██║░░░░░██╔══██╗██║░░░██║████╗░██║██╔══██╗██║░░██║██╔════╝██╔══██╗")
print(Fore.BLUE + " █████╗░░██║░░░░░███████║██║░░░██║██╔██╗██║██║░░╚═╝███████║█████╗░░██████╔╝")
print(Fore.BLUE + " ██╔══╝░░██║░░░░░██╔══██║██║░░░██║██║╚████║██║░░██╗██╔══██║██╔══╝░░██╔══██╗")
print(Fore.RED + " ███████╗███████╗██║░░██║╚██████╔╝██║░╚███║╚█████╔╝██║░░██║███████╗██║░░██║")
print(Fore.RED + " ╚══════╝╚══════╝╚═╝░░╚═╝░╚═════╝░╚═╝░░╚══╝░╚════╝░╚═╝░░╚═╝╚══════╝╚═╝░░╚═╝")
print(Style.RESET_ALL)
print(" \033[41m От создателей EscapeWorld〡Выбран сервер: SCreate \033[0m")
print("Проверяем обновление...")
time.sleep(2.5)
print("Проверяем файлы...")
time.sleep(2.5)
subprocess.run([my_path, username])
time.sleep(2.5)
break
#time.sleep(2.5)
elif key == "2":
option = "Выбор версии"
#os.system('cls' if os.name == 'nt' else 'clear')
print("")
print(Fore.RED + "ッ Пункт «Выбор версии» в разработке.")
print("")
#os.system('cls' if os.name == 'nt' else 'clear')
#time.sleep(1.5)
elif key == "3":
option = "Настройка лаунчера"
print("")
print(Fore.RED + "ッ Пункт «Настройка лаунчера» в разработке.")
print("")
elif key == "q":
break
print(option) # no response
Ответы (2 шт):
Автор решения: NTA
→ Ссылка
from json import load
fl = open('путь до json файла.json')
json_data = load(fl)
fl.close()
fl = open('путь до bat файла.bat', 'w')
fl.write(f'start game username {json_data["username"]} nogui stop sound'
fl.close()
Автор решения: Amgarak
→ Ссылка
Если хотите через subprocess, то вот вам небольшой пример:
import subprocess
import json
# Открываем JSON
with open('file.json', 'r', encoding='utf-8') as file:
data = json.load(file)
# Забираем имя из словаря
username = data['username']
print(username)
# Запуск батника с параметрами
subprocess.run(["mybat.bat", username])
Сам батник:
@echo off
echo Привет, %1
set arg1=%1
start game %arg1%
pause