请教高人:python语言中用Tkinter怎样设置窗口背景为图片?
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了请教高人:python语言中用Tkinter怎样设置窗口背景为图片?相关的知识,希望对你有一定的参考价值。
参考技术A 这么高级的问题,还是别来百度知道问啦。推荐去csdn或者豆瓣python小组
http://webdev.csdn.net/python
http://www.douban.com/group/python/本回答被提问者采纳
请教大一C语言编程,谢谢了!
就这四个题目,请给出程序及程序注释:说明本程序中用到的所有抽象数据类型的定义、主程序的流程以及各程序模块之间的层次(调用)关系,解释算法等。谢谢了!符合条件的一定会有加分的。
第一题:文件数据的处理
两个文件:data1.txt和data2.txt,两个文件中都有很多数字,用空格隔开。如:
45 78 85 45 63 21 47 86
运行程序,计算这两个文件中数字的交集,并且排好序,存放在jiao.txt中;计算这两个文件中数字的并集,并且排好序,存放在bing.txt中。
第二题:统计字符出现的频率
文件conf.txt中保存了很多字母,如:
akdsjfkasdfjaksfjdaksdfjaskldjfaieakjdkfkadsjfiwejfkasdjf
运行程序,计算这个文件中各个字母出现的频率,频率=出现的次数/总字母数。将频率存储在文件rate.txt中。格式为:
a:3.2%
k:3.8%
……
第三题:翻译软件模拟
文件ciku.txt中保存了一些词语的中英对应,格式如下:
China=中国
Hello=你好
……
界面上输入一个英文,能够翻译成中文。建议用DEVC++完成。
如输入:Hello China
显示:中国 你好
第四题:文字替换
在文件content.txt中有一些内容。
编写程序,输入字符串1和字符串2,能将content.txt 字符串1替换成字符串2,保存为newContent.txt。
只要能回答其中任何一道题即可得分啊!!!同志们,拜托了!加油啊!谢谢~~
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
/*
两个文件:data1.txt和data2.txt,两个文件中都有很多数字,用空格隔开。如:
45 78 85 45 63 21 47 86
运行程序,计算这两个文件中数字的交集,并且排好序,存放在jiao.txt中;计算这两个文件中数字的并集,并且排好序,存放在bing.txt中
*/
void QuestionOne()
FILE *pD1 = fopen("data1.txt","rt");
FILE *pD2 = fopen("data2.txt","rt");
int Arr1Size = 0;
int Arr2Size = 0;
int ArrResultSize = 0;
int *pArr1 = NULL;
int *pArr2 = NULL;
int *pArrResult = NULL;
if ( NULL == pD1 || NULL == pD2 )
printf("无data1.txt或data2.txt文件");
return;
while ( !feof(pD1) )
pArr1 = (int *)realloc(pArr1,sizeof(int) * (Arr1Size + 1) );
fscanf(pD1,"%d",&(pArr1[Arr1Size]));
Arr1Size++;
if ( feof(pD1) )
break;
else
char tc = 0;
fscanf(pD1," ",&tc);
fclose(pD1);
while ( !feof(pD2) )
pArr2 = (int *)realloc(pArr2,sizeof(int) * (Arr2Size + 1) );
fscanf(pD2,"%d",&(pArr2[Arr2Size]));
Arr2Size++;
if ( feof(pD2) )
break;
else
char tc = 0;
fscanf(pD2," ",&tc);
fclose(pD2);
for ( int i = 0 ; i < Arr1Size ; i++ )
for ( int j = 0 ; j < Arr2Size ; j++ )
if ( pArr1[i] == pArr2[j] )
pArrResult = (int *)realloc(pArrResult,sizeof(int) * (ArrResultSize + 1) );
pArrResult[ArrResultSize] = pArr1[i];
ArrResultSize++;
break;
free(pArr1);
free(pArr2);
//排序
for ( int i = 0 ; i < ArrResultSize - 1 ; i++ )
for ( int j = i + 1 ; j < ArrResultSize ; j++ )
if ( pArrResult[i] > pArrResult[j] )
int Tmp = pArrResult[j];
pArrResult[j] = pArrResult[i];
pArrResult[i] = Tmp;
for ( int i = 0 ; i < ArrResultSize ; i++ )
printf("%d,",pArrResult[i]);
free(pArrResult);
/*
文件conf.txt中保存了很多字母,如:
akdsjfkasdfjaksfjdaksdfjaskldjfaieakjdkfkadsjfiwejfkasdjf
运行程序,计算这个文件中各个字母出现的频率,频率=出现的次数/总字母数。将频率存储在文件rate.txt中。格式为:
a:3.2%
k:3.8%
……
*/
struct cc
char C;
int Num;
;
void CountChar()
FILE *pF = fopen("conf.txt","rt");
int CCount = 0;
bool HasFoundOld = false;
struct cc * pTheCharCount = NULL;
if ( NULL == pF )
printf("\n无conf.txt文件");
return;
while ( ! feof(pF) )
int i = 0;
char Tmp = 0;
fscanf(pF,"%c",&Tmp);
HasFoundOld = false;
for ( i = 0 ; i < CCount ; i++ )
if ( pTheCharCount[i].C == Tmp )
HasFoundOld = true;
break;
if ( HasFoundOld )
pTheCharCount[i].Num++;
else
if ( 0 != Tmp )
pTheCharCount = (struct cc *)realloc(pTheCharCount,sizeof(struct cc) * (CCount + 1) );
pTheCharCount[CCount].C = Tmp;
pTheCharCount[CCount].Num = 1;
CCount++;
fclose(pF);
int TheCharTotalNum = 0;
for ( int i = 0 ; i < CCount ; i++ )
TheCharTotalNum += pTheCharCount[i].Num;
for ( int i = 0 ; i < CCount ; i++ )
printf("%c:%5.1f%%\n",pTheCharCount[i].C,(double)(pTheCharCount[i].Num)/(double)(TheCharTotalNum) * 100);
free(pTheCharCount);
void main(void)
QuestionOne();
printf("\n--------------------------\n");
CountChar();
fflush(stdin);
getchar();
三:
#include <iostream>
#include <fstream>
#include <string>
#include <map>
#include <algorithm>
#include <vector>
#include <iterator>
using namespace std;
map<string, string> ssMap;
vector<string> sVec;
void read()
fstream fin("ciku.txt");
string s, s1, s2;
if(fin)
while (getline(fin, s))
int pos = s.find_first_of("=");
s1 = s.substr(0, pos);
s2 = s.substr(pos + 1, s.size());
ssMap.insert(pair<string, string>(s1, s2));
fin.close();
return;
int main()
read();
char str[100];
gets(str);
printf("%s\n", str);
string s(str);
int n = 0;
while(true)
int pos = s.find_first_of(" ", n);
string tmp = s.substr(n, pos - n);
sVec.push_back(tmp);
n = pos + 1;
if(pos == -1)
break;
cout << sVec.size() << endl;
vector<string>::iterator iter1;
for(iter1 = sVec.begin() ; iter1 != sVec.end() ; ++iter1)
//cout << *iter1 << endl;
cout << ssMap[*iter1] << " ";
cout << endl;
system("pause");
就三题,谢谢 参考技术A 其它的类似,我只写前两个:
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
/*
两个文件:data1.txt和data2.txt,两个文件中都有很多数字,用空格隔开。如:
45 78 85 45 63 21 47 86
运行程序,计算这两个文件中数字的交集,并且排好序,存放在jiao.txt中;计算这两个文件中数字的并集,并且排好序,存放在bing.txt中
*/
void QuestionOne()
FILE *pD1 = fopen("data1.txt","rt");
FILE *pD2 = fopen("data2.txt","rt");
int Arr1Size = 0;
int Arr2Size = 0;
int ArrResultSize = 0;
int *pArr1 = NULL;
int *pArr2 = NULL;
int *pArrResult = NULL;
if ( NULL == pD1 || NULL == pD2 )
printf("无data1.txt或data2.txt文件");
return;
while ( !feof(pD1) )
pArr1 = (int *)realloc(pArr1,sizeof(int) * (Arr1Size + 1) );
fscanf(pD1,"%d",&(pArr1[Arr1Size]));
Arr1Size++;
if ( feof(pD1) )
break;
else
char tc = 0;
fscanf(pD1," ",&tc);
fclose(pD1);
while ( !feof(pD2) )
pArr2 = (int *)realloc(pArr2,sizeof(int) * (Arr2Size + 1) );
fscanf(pD2,"%d",&(pArr2[Arr2Size]));
Arr2Size++;
if ( feof(pD2) )
break;
else
char tc = 0;
fscanf(pD2," ",&tc);
fclose(pD2);
for ( int i = 0 ; i < Arr1Size ; i++ )
for ( int j = 0 ; j < Arr2Size ; j++ )
if ( pArr1[i] == pArr2[j] )
pArrResult = (int *)realloc(pArrResult,sizeof(int) * (ArrResultSize + 1) );
pArrResult[ArrResultSize] = pArr1[i];
ArrResultSize++;
break;
free(pArr1);
free(pArr2);
//排序
for ( int i = 0 ; i < ArrResultSize - 1 ; i++ )
for ( int j = i + 1 ; j < ArrResultSize ; j++ )
if ( pArrResult[i] > pArrResult[j] )
int Tmp = pArrResult[j];
pArrResult[j] = pArrResult[i];
pArrResult[i] = Tmp;
for ( int i = 0 ; i < ArrResultSize ; i++ )
printf("%d,",pArrResult[i]);
free(pArrResult);
/*
文件conf.txt中保存了很多字母,如:
akdsjfkasdfjaksfjdaksdfjaskldjfaieakjdkfkadsjfiwejfkasdjf
运行程序,计算这个文件中各个字母出现的频率,频率=出现的次数/总字母数。将频率存储在文件rate.txt中。格式为:
a:3.2%
k:3.8%
……
*/
struct cc
char C;
int Num;
;
void CountChar()
FILE *pF = fopen("conf.txt","rt");
int CCount = 0;
bool HasFoundOld = false;
struct cc * pTheCharCount = NULL;
if ( NULL == pF )
printf("\n无conf.txt文件");
return;
while ( ! feof(pF) )
int i = 0;
char Tmp = 0;
fscanf(pF,"%c",&Tmp);
HasFoundOld = false;
for ( i = 0 ; i < CCount ; i++ )
if ( pTheCharCount[i].C == Tmp )
HasFoundOld = true;
break;
if ( HasFoundOld )
pTheCharCount[i].Num++;
else
if ( 0 != Tmp )
pTheCharCount = (struct cc *)realloc(pTheCharCount,sizeof(struct cc) * (CCount + 1) );
pTheCharCount[CCount].C = Tmp;
pTheCharCount[CCount].Num = 1;
CCount++;
fclose(pF);
int TheCharTotalNum = 0;
for ( int i = 0 ; i < CCount ; i++ )
TheCharTotalNum += pTheCharCount[i].Num;
for ( int i = 0 ; i < CCount ; i++ )
printf("%c:%5.1f%%\n",pTheCharCount[i].C,(double)(pTheCharCount[i].Num)/(double)(TheCharTotalNum) * 100);
free(pTheCharCount);
void main(void)
QuestionOne();
printf("\n--------------------------\n");
CountChar();
fflush(stdin);
getchar();
本回答被提问者采纳
以上是关于请教高人:python语言中用Tkinter怎样设置窗口背景为图片?的主要内容,如果未能解决你的问题,请参考以下文章