TGTGInsighttelegram intelligenceLIVE / telegram public index
← Python Заметки

TGINSIGHT SIMILAR POSTS

Најди сличен содржај

Изворен канал @pythonotes · Post #198 · 6 јан.

Первая директория в sys.path 🔸 Когда вы запускаете Python-интерпретатор в интерактивном режиме, в системные пути (sys.path) в самое начало добавляется текущая рабочая директория >>> for path in sys.path: ... print(f'"{path}"') "" "/usr/lib/python37.zip" "/usr/lib/python3.7" ... Первая строка пустая, что и означает текущую рабочую директорию. 🔸 Если вы запускаете интерпретатор передавая скрипт как аргумент, то история получается иная. На первом месте будет директория в которой располагается скрипт. А текущая рабочая директория игнорируется. Пишем скрипт с таким содержанием: # script.py import sys for path in sys.path: print(f'"{path}"') Запускаем python3 /home/user/dev/script.py Получаем "/home/user/dev" "/usr/lib/python37.zip" "/usr/lib/python3.7" ... 🔸 Если вы запускаете скрипт по имени модуля то на первом месте будет домашняя директория текущего юзера python3 -m script "/home/user" "/usr/lib/python37.zip" "/usr/lib/python3.7" ... Скрипт должен быть доступен для импорта На что это влияет? На видимость модулей для импорта. Если вы ждёте, что, запустив скрипт по пути, сможете импортировать модули из текущей рабочей директории, то вы ошибаетесь. Придётся добавлять путь os.getcwd() в sys.path самостоятельно или заранее объявлять переменную PYTHONPATH. #basic

Hashtags

Резултати

Пронајдени 3 слични објави

Пребарај: #realproject

当前筛选 #realproject清除筛选
Dasturlash hayoti️️ ️

@dasturlash_hayoti · Post #4116 · 27.12.2025 г., 07:38

#JavaScript#API#RealProject#webdev#dasturlash_hayoti 👨‍💻 JavaScript + API: Real loyiha Xabarlarni ro‘yxat qilib chiqarish + avtomatik yangilanish Bu bosqichda: - har bir xabar alohida chiqadi - sahifa refreshsiz yangilanadi - real chatlarga yana yaqinlashamiz 1️⃣HTML — xabar yozish va chat oynasi <!-- Xabar yozish --> <input type="text" id="message" placeholder="Xabar yozing"> <button onclick="sendMessage()">Yuborish</button> <!-- Chat ro'yxati --> <ul id="chat"></ul> ul — xabarlar ro‘yxat bo‘lib chiqishi uchun 2️⃣ JavaScript — xabar yuborish va ro‘yxatga qo‘shish <script> function sendMessage() { // Inputni chaqiramiz let input = document.getElementById("message"); // Inputdagi qiymat let msg = input.value; // Bo‘sh xabar yuborilmasligi uchun if (msg === "") return; // Serverga xabar yuborish fetch("https://jsonplaceholder.typicode.com/posts", { method: "POST", body: JSON.stringify({ text: msg }), headers: { "Content-type": "application/json" } }) .then(res => res.json()) .then(data => { // Xabarni chat ro‘yxatiga qo‘shamiz addMessage(data.text); // Inputni tozalaymiz input.value = ""; }); } </script> 3️⃣JavaScript — xabarni ro‘yxatga qo‘shish <script> function addMessage(text) { // Chat ro‘yxatini chaqiramiz let chat = document.getElementById("chat"); // Yangi xabar uchun <li> yaratamiz let li = document.createElement("li"); // Xabar matnini joylaymiz li.innerText = text; // Xabarni chatga qo‘shamiz chat.appendChild(li); } </script> Endi: - har bir xabar pastga qo‘shilib boradi - eski xabarlar yo‘qolmaydi Telegram, kommentlar, chatlar — barchasi shu mantiqda ishlaydi. ☑️Natija ⏺️JavaScript → foydalanuvchi bilan ishlaydi ⏺️API → server bilan gaplashadi ⏺️Sayt → jonli bo‘ladi ➡️Keyingi post: Enter bosilganda yuborish + real-time’ga yana yaqinlashtiramiz 🔥 💻@dasturlash_hayoti— dasturchilar hayoti va IT memlari aralash kanal😉

Dasturlash hayoti️️ ️

@dasturlash_hayoti · Post #4115 · 26.12.2025 г., 08:59

#JavaScript#API#RealProject#webdev#dasturlash_hayoti ➡️Keyingi postda nima bo‘ladi? Keyingi darsda: ⏺️ xabarlarni bitta emas, ro‘yxat qilib chiqaramiz ⏺️ yangi xabar kelganda sahifa avtomatik yangilanadi Ya’ni: ❌ refresh yo‘q ☑️ real-time ishlash Post JavaScript + API asosida, to‘liq real loyiha ko‘rinishida bo‘ladi. 👉O‘tkazib yubormang! 💻@dasturlash_hayoti— dasturchilar hayoti va IT memlari aralash kanal😉

Dasturlash hayoti️️ ️

@dasturlash_hayoti · Post #4113 · 24.12.2025 г., 12:44

#JavaScript#API#RealProject#webdev#dasturlash_hayoti ⚠️⚠️⚠️ Diqqat, JavaScript o‘rganuvchilar! Keyingi post: ❌ faqat nazariya emas ☑️JavaScript + API orqali real loyiha bo‘ladi Ya’ni: ⏺️serverdan ma’lumot olish ⏺️sahifani yangilamasdan ishlash ⏺️hammasi real kod bilan💻 Shunaqa amaliy post kerakmi? 👍 Ha, JS + API bilan 🔥 Yo'q, shart emas Qiziqish bo‘lsa — bosqichma-bosqich tushuntirib chiqaramiz