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

TGINSIGHT SIMILAR POSTS

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

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

Заметка начинающим, которые часто сталкиваются с подобной непоняткой. Ситуация следующая, есть список файлов: names = [ 'image.bmp', 'second.txt.bkp', 'data.db', '.config.cfg', 'file.ext.bkp' ] И мы хотим убрать у них окончание ".bkp". Не знаю зачем, пример довольно надуманный) Но суть он показывает, а это главное. Те, кто еще не очень знаком с библиотекой os.path или pathlib, вероятно решат обработать имена как строки. И тут вполне подойдет метод строки strip(). Что делает этот метод? Он отрезает указанные символы по обеим сторонам строки. Если ничего не указать, то убирает невидимые символы (пробелы, табуляции и переносы строк). В нашем случае будет выглядеть вот так: >>> name.strip('.bkp') То есть просим удалить строку '.bkp' по краям имени файла, если таковая есть. Можно применить аналогичный метод rstrip(), чтобы отрезать только справа, но для этого примера используем обычный. >>> for name in names: >>> print(name.strip('.bkp')) image.bm second.txt data.d config.cfg file.ext Хм, что-то не то с нашими именами! Что случилось??? Видим нежелательное переименование в именах, где и близко не было указанной строки '.bkp' А дело всё в том, что данный метод ищет не указанную строку, а указанные символы, и не важно в каком порядке. Для метода strip() строка '.bkp' это не паттерн для поискаа список символов. Потому он отрезал симовол 'p' от '.bmp' и удалил точку из файла '.config.cfg'. Как тогда правильно заменить именно паттерн? Для начинающего можно посоветовать метод строки replace(), который как раз использует для замены указанную строку целиком. В нашем примере заменим её на пустую строку. >>> for name in names: >>> print(name.replace('.bkp', '')) image.bmp second.txt data.db .config.cfg file.ext Уже лучше, но помните, это лишь пример про strip(). Для работы с именами файлов есть способы и более "правильные", дающие однозначно верный результат. Я взял файлы только в качестве примера. Даже replase() тут может сделать не то что ожидаем. Просто впредь будьте внимательны с этим strip(). #basic

Hashtags

Резултати

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

Пребарај: #modules

当前筛选 #modules清除筛选
djangoproject

@djangoproject · Post #328 · 03.05.2017 г., 19:27

http://www.csestack.org/python-list-installed-modules-versions-pip/ The main strength of the Python is, the wide range of external #libraries are available. As we keep coding in Python, we install many packages. It is easy getting a Python list installed #modules on the system. There are a couple of ways you can do that.

纯情男高

@hanzichen · Post #1403 · 28.11.2025 г., 00:32

Vanadium WebView & Browser Installer A Magisk/KernelSU module that changes the system WebView with Vanadium WebView and installs the Vanadium Browser. 🔗 Links: - Download - Features - Prerequisites - Support group - Source code Developer: NoneBaiano Banner by @rkbdi (from Ultimatum browser inspiration) ❤️ Support the Project If this project makes your life easier, here are a few quick ways to show some love: ⭐ Star the repo/app ☕ Buy a coffee for the developer 🛠 Contribute code, issues, or pull-requests. 🏷 Tags: #Android#Root#Modules

纯情男高

@hanzichen · Post #787 · 14.06.2025 г., 09:07

pairipfix This LSPosed module bypasses the "Get this app from Play" screen that appears when installing Android apps as an APK instead of from the Google Play Store. 🔗 Links: - Download - Source code Developer: ahmedmani ❤️ Support the Project If this project makes your life easier, here are a few quick ways to show some love: ⭐ Star the repo/app ☕ Buy a coffee for the developer 🛠 Contribute code, issues, or pull-requests 🏷 Tags: #Android#Xposed#Modules

纯情男高

@hanzichen · Post #1400 · 28.11.2025 г., 00:25

AnghamiPlus AnghamiPlus is a sophisticated Xposed module that enhances your Anghami music streaming experience by unlocking plus-like features directly on the client side. Built with a modular and safe hooking architecture, it provides plus functionality without modifying server behavior or compromising your account security. 🔗 Links: - Download - Features - How to use - Support group and channel - Source code Developer: Kero309x ❤️ Support the Project If this project makes your life easier, here are a few quick ways to show some love: ⭐ Star the repo/app ☕ Buy a coffee for the developer 🛠 Contribute code, issues, or pull-requests ⚠️ This app might be breaking copyright laws, use at your own risk. We are not responsible for anything. We are just sharing open source software. 🏷 Tags: #Android#Music#Xposed#LSPatch#Modules

djangoproject

@djangoproject · Post #456 · 04.10.2017 г., 02:57

http://www.techbeamers.com/python-tutorial-essentials-of-python-socket-programming/ Essentials of Python #Socket Programming You Should Know Python offers two types of #API libraries that we can use for socket programming. At the low-level, Python utilizes the “socket” library to implement #client and #server#modules for both #connectionless and #connection-oriented #network protocols. Whereas, at the higher-level, You can use libraries like #ftplib and #httplib to interact with application-level network protocols like #FTP and #HTTP.

djangoproject

@djangoproject · Post #513 · 30.11.2017 г., 22:00

#AI#Artificial_Intelligence #AJAX #aiohttp #Anaconda #AngularJS #API #Atom #AWS #asyncio (#Asynchronous) #audio #automated_testing #automation #atexit #BeeWare #Big_Data #bitcoin #blockchain #Bluemix #Brython #button #Celery #client #class #classmethod #concurrency #Coroutine #cron #CSS #curl #data_analysis #data_mining #data_processing #database #Deep_Learning#deep_learning #Debian #decorator #deploy #dict #dispatch #django #django_cms #Django_REST_Framework #dropdownbox #Docker #event #Firefox #Flask #form #functions #Generator #GeoDjango #git #Google #GPU #GUI #Gym #host #HTML #httplib #learn #Image_processing #intelligence #input #Instagram #IOT #iPython #Jupyter #lambda #learn #License #Linux #lists #machine_learning #Magenta #map #Matplotlib #Metaprogramming #Micro_services #Micropython #mind #monitoring #MongoDB #modules #Mozilla #Multipart #multi_touch_apps #multiprocessing #Nodes #NoSQL #numeric_computation #numerical #NumPy #network #neural_network #OAuth #object_serialization #OCR #overloading #package #parallel #pipeline #protocols #PostGIS #pyAudioAnalysis #pycon #Pyflakes #PyInstaller #PyPI #PyQt #PySide #PyTorch #pytest #python #Pyvideo_archives #Qt #Raspberry_Pi #React #Redis #random #request #Regular_Expressions (#re) #REST #RSS #satellite #scikit_learn #SciPy #scrapy #searching #selectbox #Selenium #serialization #server #sessions #single_responsibility_principle #socket #Spark #str #submit #task #telegram #template #TensorFlow #test #text_boxes #text #tuples #unicode #Universe #Unix #unit_test #urllib #upload #uWSGI #Web #WSGI