python_francais | Unsorted

Telegram-канал python_francais - Python en français

2692

Grupe à propos du language de programmation Python où on parle Français.

Subscribe to a channel

Python en français

for i in range(10):
print("Bonjour")

Читать полностью…

Python en français

Écrire un programme python qui permet d'afficher bonjour 10 fois

Читать полностью…

Python en français

Windows
--> python non_du_fichier.py
Linux
~ python3 non_du_fichier.py

Читать полностью…

Python en français

Comment faire pour exécuter un programme dans python ?

Читать полностью…

Python en français

J'aimerais bien t'aider mais j'ai du mal à suivre tu peux envoyer les fichiers ?

Читать полностью…

Python en français

Salut ?
Quand tu partages de codes, ne mets pas tes clés API...pour la confidentialité...

Читать полностью…

Python en français

await update.callback_query.edit_message_text(
text=f"Join our official community to suggest improvements and discuss the bot. We're always open to your feedback!\n\nJoin here: {user_channel_link}",
reply_markup=reply_markup
)

# Fonction pour traiter la question de l'utilisateur
async def inline_query(update: Update, context: ContextTypes.DEFAULT_TYPE):
user_id = update.inline_query.from_user.id
query = update.inline_query.query

# Vérification du nombre de questions restantes
if USER_DATA[user_id]['questions_left'] <= 0 and not USER_DATA[user_id]['paid']:
await update.inline_query.answer(
[InlineQueryResultArticle(
id=uuid.uuid4(),
title="Limit Reached",
input_message_content=InputTextMessageContent(
"You've reached your limit of free questions. Please subscribe to the paid plan to ask more.",
parse_mode=ParseMode.MARKDOWN
)
)]
)
return

if len(query) < 1:
return

prompt = f"Provide an ethical response to the following query: {query}"

# Appel à OpenAI pour obtenir une réponse
try:
response = openai.Completion.create(
model="text-davinci-003",
prompt=prompt,
max_tokens=150
)

message = response.choices[0].text.strip()
messages = split_message(message)
results = []

# Décrémenter les questions gratuites
if USER_DATA[user_id]['questions_left'] > 0:
USER_DATA[user_id]['questions_left'] -= 1

# Envoi de la réponse en plusieurs messages si elle est longue
for msg in messages:
result = InlineQueryResultArticle(
id=uuid.uuid4(), # ID unique pour chaque réponse
title="Response",
input_message_content=InputTextMessageContent(msg, parse_mode=ParseMode.MARKDOWN)
)
results.append(result)

await update.inline_query.answer(results)

except Exception as e:
await update.inline_query.answer(
[InlineQueryResultArticle(
id=uuid.uuid4(),
title="Error",
input_message_content=InputTextMessageContent(f"An error occurred: {str(e)}", parse_mode=ParseMode.MARKDOWN)
)]
)

# Fonction principale pour gérer les mises à jour et démarrer le bot
async def main():
application = (
ApplicationBuilder()
.token(TELEGRAM_TOKEN)
.build()
)

application.add_handler(CommandHandler("start", start))
application.add_handler(CallbackQueryHandler(handle_pay, pattern="^pay$"))
application.add_handler(CallbackQueryHandler(go_to_chat, pattern="^chat$"))
application.add_handler(CallbackQueryHandler(improvements, pattern="^improvements$"))
application.add_handler(InlineQueryHandler(inline_query))

await application.run_polling()

if name == "main":
import asyncio

try:
loop = asyncio.get_running_loop()
if loop.is_running():
loop.create_task(main())
else:
loop.run_until_complete(main())
except RuntimeError as e:
if str(e) == "This event loop is already running":
loop = asyncio.get_running_loop()
loop.run_until_complete(main())
else:
raise

Читать полностью…

Python en français

Flet est une option frère, facile à prendre en main

Читать полностью…

Python en français

Alors comment on peu t'aider ?

Читать полностью…

Python en français

Bonjour les développeurs, au fait j' ai un projet qui me casse la tête si vous pouvez m'aider à résoudre le problème :
J'ai créer une interface utilisateur avec tkinter dans un fichier et un autre fichier pour les requêtes SQL depuis le fichier tkinter. Maintenant j'ai voulu créer un troisième fichier pour les requêtes SQL depuis ma base de données qui doit avoir comme tâche: aller chercher des informations depuis la base de et les affiches dans des colonnes TREEVIEW du module ttk.treeview.

Читать полностью…

Python en français

Quel branche ? Parce que python avancé dans le web? Mobile? Ect.

Читать полностью…

Python en français

On peu t'aider tant que tu y mets du tiens

Читать полностью…

Python en français

Python Basics_ A Practical Introduction to Python 3.pdf

Читать полностью…

Python en français

Je suis allé sur opera c'est toujours la même chose

Читать полностью…

Python en français

Alternative peu tu changer de navigateur, a la place utilise edge

Читать полностью…

Python en français

Écrire un programme python qui permet d'afficher bonjour 10 fois

Читать полностью…

Python en français

D'accord merci beaucoup

Читать полностью…

Python en français

Votre question est tellement délicate qu'il n'est pas facile d'y répondre.
Que voulez-vous faire ?
1. Exécuter un script.py ?
2. Exécuter un programme externe ?
Ex : python import subprocess

# Ouvrir notepad
subprocess.run(["notepad"])
3. Exécuter un programme interne ?
4. Exécuter un code : main ?
5. Ouvrir un fichier quelconque
Ex: Python import subprocess

# Ouvre un fichier dans le Bloc-notes
subprocess.run(["notepad", "mon_fichier.txt"])

Etc

Читать полностью…

Python en français

N'envoyez pas des photos de l'écran ni des fichiers avec le code. Si le code est court, veuillez le formater comme monospace. Pour partager plus de 5 lignes du code ou des erreurs, s'il vous plaît, utilisez un service comme ceux là :

- pastebin.com
- repl.it
- gist.github.com

Читать полностью…

Python en français

Pouvez-vous le mettre dans un fichier ?
Ça nous aidera à bien lire et analyser

Читать полностью…

Python en français

A vraie dire je suis un apprenti en python qui n'a pas encore compris les boucles

Читать полностью…

Python en français

Je ne sais pas omment on partage les codes ici mais je voulais juste vous faire par de ma difficulté. Je suis bloqué sur les fait que je n'arrive pas à gérer les boucles d'éveènement et j'ai toujours un message d'erreur soit avec loop() soit avec asyncio.getimport logging
from telegram import InlineKeyboardButton, InlineKeyboardMarkup, Update, InlineQueryResultArticle, InputTextMessageContent
from telegram.constants import ParseMode
from telegram.ext import (
Application,
ApplicationBuilder,
CommandHandler,
CallbackQueryHandler,
MessageHandler,
filters,
InlineQueryHandler,
ContextTypes
)
import openai
import uuid

# API Keys Configuration
TELEGRAM_TOKEN = "8089899329:AAEdFh10yJ2_38cGL44Yst2WUnsh_2fXsfk"
OPENAI_API_KEY = "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"

# Initialize OpenAI
openai.api_key = OPENAI_API_KEY

# Fonction de découpe des messages longs en plusieurs petits messages
def split_message(message, limit=4096):
return [message[i:i+limit] for i in range(0, len(message), limit)]

# Fonction pour gérer les données utilisateur (compteur de questions)
USER_DATA = {}

# Fonction de traitement des commandes pour démarrer le bot
async def start(update: Update, context: ContextTypes.DEFAULT_TYPE):
user_id = update.message.from_user.id
chat_id = update.message.chat.id

# Initialiser le compteur de questions si nécessaire
if user_id not in USER_DATA:
USER_DATA[user_id] = {'questions_left': 3, 'paid': False}

# Définir les boutons
keyboard = [
[InlineKeyboardButton("Chat", callback_data="chat")],
[InlineKeyboardButton("Pay $9.99 in Bitcoin", callback_data="pay")],
[InlineKeyboardButton("Improvements", callback_data="improvements")]
]

reply_markup = InlineKeyboardMarkup(keyboard)
await update.message.reply_text(f"Hey! I'm Endji, your hacking assistant. What do you want to hack today?", reply_markup=reply_markup)

# Fonction pour gérer le paiement
async def handle_pay(update: Update, context: ContextTypes.DEFAULT_TYPE):
user_id = update.callback_query.from_user.id

keyboard = [
[InlineKeyboardButton("Go back to Chat", callback_data="chat")]
]
reply_markup = InlineKeyboardMarkup(keyboard)

# Afficher l'adresse BTC pour le paiement
await update.callback_query.edit_message_text(
text="To access the full features of the bot, please pay $9.99 using Bitcoin.\n\nSend payment to the following address: **bc1qak3hn29depe7mprpm00alkret6jnzlm0qy6cq66gr34stjke6n6s34st7v**\n\nAfter sending, click below to return to Chat.",
reply_markup=reply_markup
)

# Modifier l'état payé pour cet utilisateur après paiement
USER_DATA[user_id]['paid'] = True

# Fonction de retour aux chats après paiement
async def go_to_chat(update: Update, context: ContextTypes.DEFAULT_TYPE):
user_id = update.callback_query.from_user.id

# Afficher l'écran principal
keyboard = [
[InlineKeyboardButton("Chat", callback_data="chat")],
[InlineKeyboardButton("Pay $9.99 in Bitcoin", callback_data="pay")],
[InlineKeyboardButton("Improvements", callback_data="improvements")]
]

reply_markup = InlineKeyboardMarkup(keyboard)

await update.callback_query.edit_message_text(
text=f"Hey! I'm Endji, your hacking assistant. What do you want to hack today?",
reply_markup=reply_markup
)

# Fonction pour gérer les améliorations du bot (canal spécifique que tu gères)
async def improvements(update: Update, context: ContextTypes.DEFAULT_TYPE):
# Lien vers ton propre canal de suggestions d'amélioration
user_channel_link = "/channel/YourImprovementChannel" # Remplace par le lien réel de ton canal

keyboard = [
[InlineKeyboardButton("Go back to Chat", callback_data="chat")]
]
reply_markup = InlineKeyboardMarkup(keyboard)

Читать полностью…

Python en français

Pour le mobile tu as déjà essayé kivy.md?

Читать полностью…

Python en français

C'est à dire les imprimer dans des colonnes ttk.treeview de l'interface utilisateur !

Читать полностью…

Python en français

Dans le mobile frère

Читать полностью…

Python en français

j'ai finie avec la decclaration de variable et la creation de petit programme excecutable sur ma machine, a present besoin de tuto pour la creation de choses vraiment productrices...Help me

Читать полностью…

Python en français

Salut esque ya quelqu'un qui peut m'aider de comprendre la langage python ?

Читать полностью…

Python en français

J'envoie le fichier Inbox

Читать полностью…

Python en français

Je suis déjà sur edge

Читать полностью…

Python en français

Pourtant j'arrive à rentrer sur d'autres sites web

Читать полностью…
Subscribe to a channel